//
//  Game.m
//  YouthOlympic2014
//
//  Created by Li Yuhang on 14-7-1.
//  Copyright (c) 2014年 mitian. All rights reserved.
//

#import "Game.h"

@implementation Game
@synthesize id,name,subname,picTag,imageName,days;

+ (NSArray*/*Game*/) instanceList: (NSDictionary*)jsonData{
    NSArray *jsonGames = (NSArray*)jsonData[@"GameTypeInfo"];
    NSMutableArray* /*Game*/ games = [[NSMutableArray alloc]init];
    //
    for(int i=0; i< jsonGames.count ; i++){
        Game* game = [[Game alloc]init];
        NSDictionary* gameJson = jsonGames[i];
        game.id = gameJson[@"id"];
        NSArray* nameArr = [gameJson[@"name"] componentsSeparatedByString:@","];
        game.name = nameArr[0];
        game.subname = nameArr[1];
        game.picTag = gameJson[@"pic"];
        [games addObject:game];
    }
    
    return [NSArray arrayWithArray:games];
}


- (UIImage*)icon{
    return [UIImage imageNamed:self.picTag];
}


-(NSString *)description{
    return [NSString stringWithFormat: @"{id:%@, name:%@, subname:%@, picTag:%@}", self.id, self.name, self.subname, self.picTag];
}


@end
